@firedrill-tools/unstructured 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +275 -0
  3. package/firedrill/agent.target.json +16 -0
  4. package/firedrill/baseline.scenario.json +5 -0
  5. package/firedrill/conformance.suite.json +21 -0
  6. package/firedrill/overloaded.scenario.json +11 -0
  7. package/firedrill/rate-limited.scenario.json +11 -0
  8. package/firedrill/run-response-lost.scenario.json +11 -0
  9. package/firedrill/small-responses.scenario.json +21 -0
  10. package/firedrill/tight-limits.scenario.json +21 -0
  11. package/firedrill/tools/unstructured/behavior.mjs +69 -0
  12. package/firedrill/tools/unstructured/lib/connectors.mjs +68 -0
  13. package/firedrill/tools/unstructured/lib/errors.mjs +58 -0
  14. package/firedrill/tools/unstructured/lib/gzip.mjs +38 -0
  15. package/firedrill/tools/unstructured/lib/identity.mjs +19 -0
  16. package/firedrill/tools/unstructured/lib/ids.mjs +36 -0
  17. package/firedrill/tools/unstructured/lib/jobs-derive.mjs +92 -0
  18. package/firedrill/tools/unstructured/lib/multipart.mjs +171 -0
  19. package/firedrill/tools/unstructured/lib/pages.mjs +40 -0
  20. package/firedrill/tools/unstructured/lib/partition/chunk.mjs +243 -0
  21. package/firedrill/tools/unstructured/lib/partition/csv.mjs +85 -0
  22. package/firedrill/tools/unstructured/lib/partition/csvout.mjs +25 -0
  23. package/firedrill/tools/unstructured/lib/partition/elements.mjs +171 -0
  24. package/firedrill/tools/unstructured/lib/partition/email.mjs +269 -0
  25. package/firedrill/tools/unstructured/lib/partition/html-tokens.mjs +134 -0
  26. package/firedrill/tools/unstructured/lib/partition/html-util.mjs +99 -0
  27. package/firedrill/tools/unstructured/lib/partition/html.mjs +211 -0
  28. package/firedrill/tools/unstructured/lib/partition/index.mjs +122 -0
  29. package/firedrill/tools/unstructured/lib/partition/markdown.mjs +220 -0
  30. package/firedrill/tools/unstructured/lib/partition/other.mjs +118 -0
  31. package/firedrill/tools/unstructured/lib/partition/text.mjs +53 -0
  32. package/firedrill/tools/unstructured/lib/sha256.mjs +161 -0
  33. package/firedrill/tools/unstructured/lib/store.mjs +33 -0
  34. package/firedrill/tools/unstructured/lib/util.mjs +149 -0
  35. package/firedrill/tools/unstructured/lib/validate.mjs +115 -0
  36. package/firedrill/tools/unstructured/lib/wire-multipart.mjs +78 -0
  37. package/firedrill/tools/unstructured/lib/wire.mjs +154 -0
  38. package/firedrill/tools/unstructured/ops/connectors.mjs +129 -0
  39. package/firedrill/tools/unstructured/ops/jobs.mjs +83 -0
  40. package/firedrill/tools/unstructured/ops/nodes.mjs +107 -0
  41. package/firedrill/tools/unstructured/ops/partition.mjs +112 -0
  42. package/firedrill/tools/unstructured/ops/workflows.mjs +180 -0
  43. package/firedrill/tools/unstructured/unstructured.tool.json +4892 -0
  44. package/firedrill/unstructured-archivist.drill.json +68 -0
  45. package/firedrill/unstructured-chunking.drill.json +67 -0
  46. package/firedrill/unstructured-connectors.drill.json +121 -0
  47. package/firedrill/unstructured-denied.drill.json +58 -0
  48. package/firedrill/unstructured-fresh-actor.drill.json +68 -0
  49. package/firedrill/unstructured-overloaded.drill.json +51 -0
  50. package/firedrill/unstructured-partition-errors.drill.json +66 -0
  51. package/firedrill/unstructured-partition.drill.json +95 -0
  52. package/firedrill/unstructured-rate-limited.drill.json +66 -0
  53. package/firedrill/unstructured-revoked-key.drill.json +773 -0
  54. package/firedrill/unstructured-run-lost.drill.json +51 -0
  55. package/firedrill/unstructured-small-responses.drill.json +173 -0
  56. package/firedrill/unstructured-tight-limits.drill.json +203 -0
  57. package/firedrill/unstructured-workflows-jobs.drill.json +167 -0
  58. package/firedrill/world.json +1556 -0
  59. package/firedrill.json +5 -0
  60. package/package.json +52 -0
  61. package/starter.json +1114 -0
  62. package/test/conformance.mjs +37 -0
  63. package/test/flows/access.mjs +54 -0
  64. package/test/flows/chunking.mjs +95 -0
  65. package/test/flows/connectors.mjs +76 -0
  66. package/test/flows/errors.mjs +115 -0
  67. package/test/flows/faults.mjs +73 -0
  68. package/test/flows/partition.mjs +225 -0
  69. package/test/flows/workflows.mjs +123 -0
  70. package/test/hostile-gen.mjs +0 -0
  71. package/test/hostile.mjs +155 -0
  72. package/test/lib.mjs +113 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Reload Tech Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,275 @@
1
+ # @firedrill-tools/unstructured
2
+
3
+ A synthetic **Unstructured** account for [Firedrill](https://firedrill.run) drills. It stands in for the two public
4
+ Unstructured HTTP surfaces so an agent that partitions documents or drives ingestion workflows can be tested locally,
5
+ deterministically and offline:
6
+
7
+ - the **Partition Endpoint** — `POST /general/v0/general` with a multipart upload, answering the familiar JSON array of
8
+ elements (`type`, `element_id`, `text`, `metadata`), optionally chunked;
9
+ - the **Workflow Endpoint** subset — source connectors, destination connectors, workflows made of partition / chunk /
10
+ embed / prompter nodes, and jobs that run a workflow over the files a source holds.
11
+
12
+ Everything is synthetic. Partitioning is a **deterministic, rule-based partition of UTF-8 text documents** (plain text,
13
+ Markdown, HTML, CSV/TSV, RFC 822 e-mail, XML and pre-partitioned Unstructured JSON). No model, OCR or layout detection
14
+ runs, no connector reaches a real bucket or vector store, and no Unstructured service is ever contacted. Firedrill owns
15
+ the state, the virtual clock and the evidence. Backend only: there is no browser app.
16
+
17
+ ## Install
18
+
19
+ ```sh
20
+ firedrill tool add @firedrill-tools/unstructured --install
21
+ firedrill serve --scenario baseline --no-open
22
+ ```
23
+
24
+ `firedrill tool add` copies the starter rows into a new world (35 rows, virtual time 2026-09-16T09:00:00Z) and grants
25
+ the default actor every operation. Existing worlds receive neither data nor grants: add the 25 `unstructured.<operation>`
26
+ grants listed below and the rows from `starter.json` yourself. Point a client at the world's HTTP origin with the
27
+ `unstructured-api-key` header set to `FIREDRILL_HTTP_TOKEN` (the declared connection recipe `unstructured-api` maps
28
+ `UNSTRUCTURED_API_URL` and `UNSTRUCTURED_API_KEY`). The real product serves the partition and platform APIs from two
29
+ different hosts; here both are routes of the world's single origin.
30
+
31
+ ## Identities
32
+
33
+ An API key belongs to one organisation workspace and sees every connector, workflow and job of that workspace. The actor
34
+ attribute `unstructuredWorkspaceId` names the workspace row (`workspaces` namespace):
35
+
36
+ | actor attribute | behaviour |
37
+ |---|---|
38
+ | absent (a fresh `firedrill tool add` actor) | falls back to the seeded default workspace `ws_northgate`; the fresh actor sees all seeded data |
39
+ | `unstructuredWorkspaceId: "ws_northgate"` / `"ws_archive"` | scoped to that workspace; records of the other workspace behave as if they did not exist (404 on get, absent from lists, 422 `Source connector not found` when referenced) |
40
+ | any other value | `401 {"detail": "API key is invalid"}` on every operation |
41
+
42
+ Framework grants decide whether an operation may be called at all; a missing grant is rendered as
43
+ `403 {"detail": "This API key is not granted this operation in the Firedrill world."}`. There is no read-only key level in
44
+ the real product, so none is modelled.
45
+
46
+ ## Starting data
47
+
48
+ The fictional **Northgate Research** account (`ws_northgate`) plus a second workspace used only for scoping tests:
49
+
50
+ - **Sources**: `Policy archive` (s3, key `policy-archive`, 7 files: `handbook.md`, `refund-policy.txt`, `vendors.csv`,
51
+ `release-notes.html`, `elements.json`, `empty.txt`, `ledger.txt`), `Field notes` (google_drive, 3 files:
52
+ `2026-09-08-site-visit.txt`, `inbound.eml`, `glossary.md` with non-ASCII text and a 2,400-character paragraph),
53
+ `Legacy scans` (azure, 2 files that always fail: an encrypted PDF and a PNG), and `Archive dump` in `ws_archive`.
54
+ - **Destinations**: `Parsed output bucket` (s3), `Policy index` (pinecone), and one s3 bucket in `ws_archive`.
55
+ - **Workflows**: `policy-ingest` (custom: partition/fast → chunk_by_title 800 chars → embed, daily), `notes-basic` (auto),
56
+ `legacy-scan` (custom, **inactive**), and `archive-flow` in `ws_archive`.
57
+ - **Jobs** (statuses derived from virtual time): two `COMPLETED` runs of `policy-ingest` (the download fixtures), one
58
+ `STOPPED` and one `IN_PROGRESS` run of `notes-basic`, one `FAILED` run of `legacy-scan` (both files failed), and one
59
+ `SCHEDULED` run of `policy-ingest` created two seconds before virtual now.
60
+ - Two connection checks (`SUCCESS` for the policy archive, `FAILURE` for the legacy scans), `meta/counters` and
61
+ `meta/limits`.
62
+
63
+ Connector secrets are stored as the placeholder `********`; no value in the starter data is a real credential, address or
64
+ person. `ledger.txt` (2,800 short blocks) is deliberately large: partitioning it with chunking and `orig_elements`, or
65
+ downloading it from a finished job, exceeds the 900 KB response budget and answers `413`.
66
+
67
+ ## Operations and routes
68
+
69
+ All routes authenticate with the `unstructured-api-key` header (the framework compares it with the world's HTTP token).
70
+ Platform collection routes take **no trailing slash** (`/api/v1/sources`); the OpenAPI's `/api/v1/sources/` form answers
71
+ the framework's 404 because Firedrill route templates cannot end with `/`. No MCP aliases are declared (see
72
+ *Compatibility*); the canonical `unstructured.<operation>` names are always exposed. The "UNS-MCP name" column is a
73
+ reading aid only.
74
+
75
+ | operation | UNS-MCP name (reading aid) | HTTP route |
76
+ |---|---|---|
77
+ | `general.partition` | – | `POST /general/v0/general` (multipart; JSON array or `text/csv`) |
78
+ | `sources.list` | `list_sources` | `GET /api/v1/sources?source_type=` |
79
+ | `sources.create` | `create_source_connector` | `POST /api/v1/sources` |
80
+ | `sources.get` | `get_source_info` | `GET /api/v1/sources/{source_id}` |
81
+ | `sources.update` | `update_source_connector` | `PUT /api/v1/sources/{source_id}` |
82
+ | `sources.delete` | `delete_source_connector` | `DELETE /api/v1/sources/{source_id}` → `{}` |
83
+ | `sources.check_connection` | – | `POST /api/v1/sources/{source_id}/connection-check` |
84
+ | `sources.get_connection_check` | – | `GET /api/v1/sources/{source_id}/connection-check` |
85
+ | `destinations.list` | `list_destinations` | `GET /api/v1/destinations?destination_type=` |
86
+ | `destinations.create` | `create_destination_connector` | `POST /api/v1/destinations` |
87
+ | `destinations.get` | `get_destination_info` | `GET /api/v1/destinations/{destination_id}` |
88
+ | `destinations.update` | `update_destination_connector` | `PUT /api/v1/destinations/{destination_id}` |
89
+ | `destinations.delete` | `delete_destination_connector` | `DELETE /api/v1/destinations/{destination_id}` → `{}` |
90
+ | `workflows.list` | `list_workflows` | `GET /api/v1/workflows?source_id=&destination_id=&status=&name=&page=&page_size=&sort_by=&sort_direction=` |
91
+ | `workflows.create` | `create_workflow` | `POST /api/v1/workflows` |
92
+ | `workflows.get` | `get_workflow_info` | `GET /api/v1/workflows/{workflow_id}` |
93
+ | `workflows.update` | `update_workflow` | `PUT /api/v1/workflows/{workflow_id}` |
94
+ | `workflows.delete` | `delete_workflow` | `DELETE /api/v1/workflows/{workflow_id}` → `{}` |
95
+ | `workflows.run` | `run_workflow` | `POST /api/v1/workflows/{workflow_id}/run` → 202 (empty body, or multipart `input_files` parts) |
96
+ | `jobs.list` | `list_jobs` | `GET /api/v1/jobs?workflow_id=&status=&page=&page_size=` |
97
+ | `jobs.get` | `get_job_info` | `GET /api/v1/jobs/{job_id}` |
98
+ | `jobs.cancel` | `cancel_job` | `POST /api/v1/jobs/{job_id}/cancel` → `{ id, status, message }` |
99
+ | `jobs.get_details` | – | `GET /api/v1/jobs/{job_id}/details` |
100
+ | `jobs.get_failed_files` | – | `GET /api/v1/jobs/{job_id}/failed-files` |
101
+ | `jobs.download_output` | – | `GET /api/v1/jobs/{job_id}/download?file_id=&node_id=` |
102
+
103
+ ### Partitioning
104
+
105
+ `POST /general/v0/general` accepts `files` parts (several are consolidated into one array in part order) and the
106
+ parameters that affect text partitioning and chunking: `content_type`, `strategy` (`auto|fast|hi_res|ocr_only|vlm`,
107
+ validated and otherwise inert), `output_format` (`application/json` or `text/csv`), `encoding` (UTF-8/ASCII names only),
108
+ `languages[]` (recorded in metadata whole; at most 20 entries of at most 20 characters, otherwise a 422), `include_page_breaks`, `starting_page_number`, `unique_element_ids`,
109
+ `xml_keep_tags`, `chunking_strategy` (`basic|by_title|by_page`), `max_characters`, `new_after_n_chars`, `overlap`,
110
+ `overlap_all`, `combine_under_n_chars`, `multipage_sections`, `include_orig_elements`. `split_pdf_*`, `ocr_languages`,
111
+ `include_slide_notes`, `pdf_infer_table_structure`, `skip_infer_table_types`, `extract_image_block_types` and
112
+ `coordinates` are accepted and ignored. A request `files` part sent with `Content-Transfer-Encoding: base64` is decoded before partitioning; transfer encodings *inside* an uploaded e-mail are not (see the e-mail notes below).
113
+
114
+ The file type comes from the `content_type` field, then the part's `Content-Type`, then the filename extension
115
+ (`.txt .md .html .htm .csv .tsv .json .eml .xml .rst`). Elements carry `filename`, `filetype`, `languages`,
116
+ `page_number` (form feeds and HTML `page-break` styles advance it), `last_modified`, `parent_id` (nearest preceding
117
+ Title of smaller depth), `category_depth` on titles and list items, `text_as_html` on tables, `link_texts`/`link_urls`,
118
+ `emphasized_text_contents`/`emphasized_text_tags`, and for e-mail `sent_from`, `sent_to`, `cc_recipient`,
119
+ `bcc_recipient`, `subject`, `email_message_id`. `element_id` is the first 32 hex characters of SHA-256 over filename,
120
+ page, ordinal and text (a UUID when `unique_element_ids=true`). Chunks are `CompositeElement`, `Table` or `TableChunk`
121
+ elements whose `orig_elements` is base64 of a real gzip stream (stored blocks) of the original elements — any gzip
122
+ reader and the `unstructured` library's `elements_from_base64_gzipped_json` decode it.
123
+
124
+ Each successful call writes one `partition-log` row and emits `partition.completed`, so drills can assert on a
125
+ stateless endpoint.
126
+
127
+ ### Workflows and jobs
128
+
129
+ `workflows.run` snapshots the workflow's nodes on the job and decides each file's fate immediately: a file fails when
130
+ its seeded `error` is set or the partitioner rejects it. Job **status is derived from virtual time** at every read:
131
+ `SCHEDULED` for 5 s after creation, `IN_PROGRESS` for 10 s per file plus 1 s per 4 KB, then `COMPLETED`
132
+ (`processing_status` `SUCCESS` or `COMPLETED_WITH_ERRORS`) or `FAILED` when every file failed; `jobs.cancel` on a
133
+ running job makes it `STOPPED`. Nothing happens between calls and no event is scheduled: advancing the world clock is
134
+ what "finishes" a job. `jobs.download_output` recomputes the elements of one successful file with the snapshotted
135
+ partition and chunk node settings (`file_id` and `node_id` of an `output_node_files` entry; the last node stands in for
136
+ the destination). Embed and prompter nodes are validated and inert. Schedules are stored and echoed but never fire.
137
+
138
+ ## Compatibility
139
+
140
+ `manifest.compatibility` is empty: **no official client has been exercised against this Tool.** The route shapes follow the
141
+ public Unstructured documentation, the Platform OpenAPI document and the open-source partition server
142
+ (`unstructured-api`), so `unstructured-client` (PyPI / npm) configured with `server_url = FIREDRILL_HTTP_URL` and
143
+ `api_key_auth = FIREDRILL_HTTP_TOKEN` should reach `client.general.partition`, `client.sources.*`,
144
+ `client.destinations.*`, `client.workflows.*` and `client.jobs.*` for the implemented subset, but that is untested. No
145
+ MCP aliases are declared: the only published MCP contract with these resources (UNS-MCP) is unmaintained and documents no
146
+ argument shapes, and the hosted Transform MCP server publishes no tool list.
147
+
148
+ Error bodies use the FastAPI envelopes both endpoints use: `{"detail": "<message>"}` for 400/401/403/404/413/429/500/503
149
+ and `{"detail": [{"loc": [...], "msg": "...", "type": "..."}]}` for 422 field errors (types `missing`, `int_parsing`,
150
+ `bool_parsing`, `enum`, `extra_forbidden`, `value_error`). Known deviations, all framework-level:
151
+
152
+ - Requests rejected **before any codec runs** keep the Firedrill envelope: a missing or wrong `unstructured-api-key`
153
+ (401), an unknown path or the trailing-slash collection form (404 `framework.HTTP_ROUTE_NOT_FOUND`), a wrong method on a
154
+ known path (405 `framework.HTTP_METHOD_NOT_ALLOWED` on the current framework; a 2026-09-16 build answered 404
155
+ `HTTP_ROUTE_NOT_FOUND` — either way a framework envelope, never a `{detail}`), unparsable or empty JSON on a
156
+ JSON route (400 `framework.HTTP_BODY_INVALID`), invalid UTF-8 or a body over 1 MiB.
157
+ - A schema-invalid argument (for example a 600-character id) answers **400** with the `detail` array, not 422; the codec
158
+ builds the array but the framework fixes the status.
159
+ - Binary uploads never reach the Tool: the framework decodes multipart bodies as UTF-8 text first, so a PDF or image
160
+ answers the framework's 400 `request body must be valid UTF-8`. Text files with a binary-looking name (`scan.pdf`) reach
161
+ the Tool and answer `400 {"detail": "application/pdf not currently supported"}`.
162
+ - `unstructured-api-version: 0.1.0-firedrill` is a Tool-specific response header on the partition route.
163
+ - Several wire details are assumptions recorded in `specs/unstructured/SPEC.md` until a client run settles them:
164
+ create routes answer 200 (not 201), run answers 202, deletes answer `{}`, cancel answers `{ id, status, message }`,
165
+ jobs list newest first, `Retry-After: 1` and the 429 text, the fixed CSV column set, several 422 message texts and the
166
+ `sources`/`destinations`/`reason` fields on workflow and job objects.
167
+
168
+ ## Events and faults
169
+
170
+ | id | kind | when |
171
+ |---|---|---|
172
+ | `partition.completed` | event | every successful `general.partition` (`log_id`, filenames, filetypes, strategy, chunking strategy, counts) |
173
+ | `job.created` | event | every successful `workflows.run` — also under `run-response-lost`, because that fault fires after commit |
174
+ | `job.cancelled` | event | every successful `jobs.cancel` |
175
+ | `partition-rate-limited` | fault (before) | `general.partition` → 429 `Rate limit exceeded. Please retry after a short delay.` with `Retry-After: 1`; nothing logged |
176
+ | `partition-overloaded` | fault (before) | `general.partition` → 503 `Server is under heavy load. Please try again later.` (the open server's text) |
177
+ | `run-response-lost` | fault (after commit) | `workflows.run` → 500 `Internal Server Error` although the job **was** created; a naive retry creates a second job, `jobs.list` shows the truth |
178
+
179
+ Scenarios shipped with the conformance project: `baseline`, `rate-limited`, `overloaded`, `run-response-lost`,
180
+ `tight-limits` (lowers `meta/limits` so every bounded scan fails `500 state exceeds the supported bound` instead of
181
+ truncating) and `small-responses` (lowers `meta/limits.response_bytes` to 520 so every list or page over the budget
182
+ fails `413 RESPONSE_TOO_LARGE` instead of being shortened).
183
+
184
+ ## Limitations
185
+
186
+ - **Text documents only.** PDF, Office, image, e-book and archive formats are refused (`… not currently supported`)
187
+ even though the real service supports them. No OCR, layout model, VLM, table-structure inference, coordinates, image
188
+ extraction or language detection; `strategy`, `languages`, `vlm_*`, `coordinates` and the PDF/OCR parameters are
189
+ validated or accepted and otherwise inert (`vlm` still requires `vlm_model` and `vlm_model_provider`).
190
+ - **Element classification is heuristic and Tool-specific.** Title/NarrativeText/ListItem/Address/EmailAddress rules
191
+ approximate the library for these formats but are not it; `element_id`s are deterministic but not the library's hash.
192
+ E-mail: headers end at the first empty line (CRLF, LF and bare CR line endings may be mixed; a leading mbox `From `
193
+ envelope line is skipped); `Subject`, `From`, `To`, `Cc` and `Bcc` decode RFC 2047 encoded words in UTF-8, US-ASCII or
194
+ ISO-8859-1 (other charsets stay literal), and address lists split on commas outside quoted strings, angle brackets and
195
+ comments; a multipart body is split on its RFC 2046
196
+ boundary, matched case-sensitively, and the **first text part in document order** (depth first through nested multiparts)
197
+ is partitioned — as HTML for `text/html`, as plain text otherwise. Attachments and later alternatives are not partitioned,
198
+ and `Content-Transfer-Encoding` (base64, quoted-printable) is not decoded. Malformed structure answers `422 {"detail":
199
+ "File is not a valid eml: …"}` naming it: a header line that is not a field before the blank line, a missing, empty,
200
+ over-70-character or invalid boundary, no delimiter, a delimiter with no line break after it, no close delimiter, more
201
+ than 1,000 parts, or multiparts nested deeper than 4 levels.
202
+ - **Chunking**: `basic`, `by_title`, `by_page` only; `by_similarity` is refused. `orig_elements` is a valid but
203
+ uncompressed gzip stream (larger than the real payload). A table row longer than `max_characters` becomes its own run
204
+ of `TableChunk` pieces (its markup rides with the first piece); nothing is cut. Chunk output is sized per chunk
205
+ group before any piece of that group is built: a text of L characters splits into 1 + ⌈(L − max)/(max − overlap)⌉
206
+ pieces holding L + (pieces − 1)·overlap characters (arithmetic), and every piece carries a copy of the group's metadata
207
+ (the merged `link_urls`/`link_texts`/emphasis arrays, e-mail recipients, `orig_elements`), which is built **once** per
208
+ group — linear in that group's elements, its gzip included — measured once in JSON bytes and multiplied by the piece
209
+ count. When the running total of the request (summed across its files: chunk text + pieces × metadata + 90 bytes per
210
+ chunk, a lower bound of the JSON) passes the response budget the request answers `413 {"detail": "Partition output of
211
+ at least N bytes exceeds the 921600 byte response limit; upload fewer or smaller files, raise max_characters or lower
212
+ overlap"}` before a single piece of that group exists — an `overlap` of `max_characters − 1` with `overlap_all=true`
213
+ (accepted, as the library accepts it) would otherwise multiply the text by `max_characters`, and 5,000 links or 20,000
214
+ `<b>` marks in one paragraph chunked at a small `max_characters` would otherwise multiply their metadata into
215
+ gigabytes. The pieces that are built share the group's metadata (arrays by reference, one shallow copy per piece).
216
+ The work done before each check is bounded by that group's input, never by its piece count. Workflow chunk nodes are sized the same way at run time (against the default
217
+ 921,600 bytes; the failure is recorded as the file's error) and again by `jobs.download_output`. CSV output uses a
218
+ fixed column set.
219
+ - **Workflow Endpoint subset**: no `POST /api/v1/jobs`, destination connection checks, notifications, templates,
220
+ soft-deleted or recommender listings, `created_since`/`created_before`, `source_ids`/`destination_ids` fan-out or
221
+ `skip_preflight` (all answer 422 `… not supported by this Tool` or 404). Connector `config` is checked only for the
222
+ presence of a small per-type required-key table; secrets (`secret_access_key`, `token`, `password`, `client_secret`,
223
+ `private_key`, `api_key`, …) are masked as `********` in every response and a masked value on update keeps the stored
224
+ secret. Connector and workflow `key` values must be unique within a workspace. Hard deletes only.
225
+ - **Jobs are simulated in virtual time** (see above); no page accounting or billing.
226
+ - **Bounds** (a bound fails loudly; nothing is returned shortened): 2,000 connectors, 5,000 workflows and 5,000 jobs per namespace, 200 files per
227
+ source, 32 files per request, 900 KB of runtime files per run, 900 KB per response (`meta/limits.response_bytes`),
228
+ 100,000 text blocks or elements per document, 100,000 characters per element or chunk (`max_characters`,
229
+ `new_after_n_chars`, `overlap` and `combine_under_n_chars` accept at most 100,000, else a pydantic-style 422
230
+ `less_than_equal`), 10,000 rows × 200 cells per CSV/TSV file, HTML table or Markdown pipe table, 256 levels of HTML or XML element
231
+ nesting, 512 levels of JSON nesting, 64 multipart parts per request, 10,000 header lines, 1,000 MIME parts and 4 multipart nesting
232
+ levels per e-mail, 20 `languages` entries of at most 20 characters (the partition parameter and a workflow partition
233
+ node's `settings.languages`; more is a 422 naming `languages`). Blank lines and paragraph continuation lines do not count
234
+ as text blocks. A partitioner bound is a `422 {"detail": …}` naming it —
235
+ `File has a table with more than 10000 rows`, `File has a table row with more than 200 cells`, `File is not valid
236
+ html: elements nested deeper than 256 levels` (`… not a valid xml: …` for XML), `File has more than 10000 rows` /
237
+ `… 200 columns` for CSV, `File has too many text blocks` / `File produces too many elements` — never a shortened
238
+ element. Element metadata (`link_texts`/`link_urls`, emphasis, `image_url`, e-mail recipients, `subject`,
239
+ `email_message_id`, merged chunk arrays) is never cut either: it is bounded only by the 1 MiB file cap and the
240
+ response budget below. Caller metadata on an `application/json` upload is returned exactly as given when it fits the
241
+ output schema (at most 100 keys of at most 100 characters, known keys with their type, other values scalars of at
242
+ most 10,000 characters or arrays of at most 200 scalars) and otherwise fails the whole upload with the 400 schema
243
+ message — no key, string or array is dropped from a 200. Every partitioner and chunker pass is a forward scan over the input
244
+ with explicit bounds: the HTML/XML tokenizer is one forward scan whose attribute and raw-text searches stop at their own
245
+ tag, an entity reference is looked up within the 12 code units after its `&`, the tree builder keeps an explicit stack
246
+ with per-name open counts, text is accumulated in arrays and joined once, Markdown inline searches are memoised forward
247
+ scans, the e-mail parser walks lines with an index that must advance on every iteration (a scan that did not advance
248
+ fails 422), chunk output is sized against the response budget per chunk group before any piece of that group is built
249
+ (§Chunking above), merged chunk link/emphasis arrays are copied item by item (never spread as call arguments) and fail
250
+ 413 once they pass the budget, and no backtracking regular expression runs over caller text. While elements are built a
251
+ running lower bound of their encoded size (text, id, filename, metadata strings and array items, e-mail metadata) is
252
+ checked against the response budget whenever the elements themselves are serialised (unchunked output, or
253
+ `orig_elements` against three quarters of the budget), so an oversized result answers 413 before megabytes of elements
254
+ are encoded. **Measured bound, not a proof:** `test/hostile.mjs` (see `specs/unstructured/VERIFICATION.md` §13) runs
255
+ 20,000 generated hostile inputs per seed — every format and the chunker, sizes up to just under the 1 MiB cap — directly
256
+ through the partitioner with the result JSON-encoded as the route does (every fourth case also decodes a hostile
257
+ multipart/form-data request envelope through both multipart route decoders, whose parser walks the body forward once), and fails on any case over 250 ms, any thrown
258
+ error or any undeclared error code; the worst case observed is recorded there (about 100–200 ms, reached by 1 MB inputs
259
+ that build the 100,000-element bound, where one SHA-256 element id per element dominates). Earlier HTTP measurements on
260
+ `firedrill serve` are recorded per fix round in VERIFICATION §9–§12. A namespace larger than its bound answers `500 {"detail": "state exceeds the supported bound of N <namespace>
261
+ rows"}`. Every response — element arrays, CSV, job downloads, the unpaginated `sources`/`destinations` arrays and each
262
+ `workflows`/`jobs` page — is measured in UTF-8 bytes before it is returned; one that would pass the budget answers
263
+ `413 {"detail": "… exceeds the 921600 byte response limit; lower page_size"}` (or `filter by source_type …` for the
264
+ connector lists). A page always holds exactly the requested rows or fails: it is never shortened, because a shortened
265
+ page would make the rows before the next page boundary unreachable.
266
+ - Generic `/api/v1/…` and `/general/…` paths could collide with another installed Tool that claims the same paths.
267
+
268
+ ## Trademarks
269
+
270
+ Unstructured is a trademark of its owner. The name is used only to identify the service this Tool simulates in a test
271
+ environment; there is no affiliation with or endorsement by Unstructured Technologies, Inc. No logo is shipped.
272
+
273
+ ## License
274
+
275
+ Apache-2.0 — see `LICENSE`.
@@ -0,0 +1,16 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "target": {
4
+ "id": "conformance-agent",
5
+ "kind": "command",
6
+ "bindings": [
7
+ "http"
8
+ ],
9
+ "executable": "node",
10
+ "arguments": [
11
+ "test/conformance.mjs"
12
+ ],
13
+ "workingDirectory": ".",
14
+ "timeoutMs": 120000
15
+ }
16
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "baseline",
4
+ "title": "Northgate Research account as seeded: 3 sources, 2 destinations, 3 workflows, 6 jobs, no faults"
5
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "conformance",
4
+ "title": "Unstructured Tool conformance: every operation, declared error, event and fault",
5
+ "drills": [
6
+ "unstructured-partition",
7
+ "unstructured-chunking",
8
+ "unstructured-partition-errors",
9
+ "unstructured-connectors",
10
+ "unstructured-workflows-jobs",
11
+ "unstructured-fresh-actor",
12
+ "unstructured-archivist",
13
+ "unstructured-revoked-key",
14
+ "unstructured-denied",
15
+ "unstructured-rate-limited",
16
+ "unstructured-overloaded",
17
+ "unstructured-run-lost",
18
+ "unstructured-tight-limits",
19
+ "unstructured-small-responses"
20
+ ]
21
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "overloaded",
4
+ "title": "general.partition answers 503 SERVICE_OVERLOADED with the open server's exact text; nothing is logged",
5
+ "faults": [
6
+ {
7
+ "packageId": "unstructured",
8
+ "faultId": "partition-overloaded"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "rate-limited",
4
+ "title": "general.partition answers 429 RATE_LIMITED with Retry-After: 1; nothing is logged",
5
+ "faults": [
6
+ {
7
+ "packageId": "unstructured",
8
+ "faultId": "partition-rate-limited"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "run-response-lost",
4
+ "title": "workflows.run commits the job and its event, then answers 500 Internal Server Error",
5
+ "faults": [
6
+ {
7
+ "packageId": "unstructured",
8
+ "faultId": "run-response-lost"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "small-responses",
4
+ "title": "meta/limits.response_bytes lowered to 520 so every list or page that would pass the response budget fails RESPONSE_TOO_LARGE instead of being shortened",
5
+ "state": [
6
+ {
7
+ "action": "upsert",
8
+ "packageId": "unstructured",
9
+ "namespace": "meta",
10
+ "rowId": "limits",
11
+ "value": {
12
+ "connectors": 2000,
13
+ "workflows": 5000,
14
+ "jobs": 5000,
15
+ "files_per_source": 200,
16
+ "source_file_bytes": 262144,
17
+ "response_bytes": 520
18
+ }
19
+ }
20
+ ]
21
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "tight-limits",
4
+ "title": "meta/limits lowered so every bounded scan fails INTERNAL_ERROR instead of truncating",
5
+ "state": [
6
+ {
7
+ "action": "upsert",
8
+ "packageId": "unstructured",
9
+ "namespace": "meta",
10
+ "rowId": "limits",
11
+ "value": {
12
+ "connectors": 2,
13
+ "workflows": 2,
14
+ "jobs": 2,
15
+ "files_per_source": 2,
16
+ "source_file_bytes": 262144,
17
+ "response_bytes": 921600
18
+ }
19
+ }
20
+ ]
21
+ }